<template>
  <div class="list">
    <el-breadcrumb separator="/" class="breadcrumb">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>公告列表页</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="content">
      <el-table
        class="bidTable"
        v-loading="loading"
        style="width: 100%"
        :data="biddingList"
        :header-cell-style="{
          background: '#F6FDFD',
          height: '46px',
          color: '#000000',
          border: '0px solid tan',
          boxShadow: 'inset 0px -1px 0px 0px #EEEEEE',
        }"
        :row-style="{ height: '50px' }"
        @row-click="handleTableRow"
      >
        <el-table-column
          label="序号"
          type="index"
          width="244"
        ></el-table-column>
        <el-table-column
          label="招投标标题"
          align="left"
          width="530"
          prop="bidTitle"
        />
        <el-table-column
          label="发布时间"
          align="left"
          prop="bidPublishDatetime"
        >
          <template slot-scope="scope">
            <span>{{
              parseTime(scope.row.bidPublishDatetime, "{y}-{m}-{d}")
            }}</span>
          </template>
        </el-table-column>
      </el-table>
      <div ref="mobileList" class="mobileList">
        <div
          class="mobile_item"
          v-for="(item, index) in biddingList"
          :key="index"
          @click="handleTableRow(item)"
        >
          <h4>{{ item.bidTitle }}</h4>
          <span>{{ parseTime(item.bidPublishDatetime, "{y}-{m}-{d}") }}</span>
        </div>
      </div>
      <pagination
        class="bidPagination"
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { listBidding } from "@/api/bid/bidding";

export default {
  name: "list",
  data() {
    return {
      loading: true,
      // 总条数
      total: 0,
      biddingList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        bidTitle: null,
        bidContent: null,
        bidPublishDatetime: null,
        bidPublisher: null,
        category: null,
        beginDate: null,
        endDate: null,
        status: null,
      },
      headerCellClassName: "headerClass",
      category: "0",
    };
  },
  created() {
    this.category = this.$route.query.category;
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      const that = this;
      this.loading = true;

      if (this.$refs.mobileList.offsetTop > 0) {
        this.queryParams = {};
      }

      this.queryParams.category = this.category;
      listBidding(this.queryParams).then((response) => {
        this.biddingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleTableRow(row, column, event) {
      this.$router.push(`/bid/detail?id=${row.id}`);
    },
  },
};
</script>

<style lang="scss" scoped>
.list {
  .breadcrumb {
    height: 21px;
    font-family: MicrosoftYaHei, sans-serif;
    font-size: 14px;
    font-weight: normal;
    line-height: 21px;
    letter-spacing: 0em;
    margin-left: 30px;
  }

  .content {
    margin: 14px 30px 44px 30px;
    background: #ffffff;
    border-radius: 10px;
    opacity: 1;
    width: 1380px;
    min-height: 860px;
    padding: 24px 21px 0 21px;
  }
}

.mobileList {
  display: none;
  text-align: left;
  .mobile_item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px #e6e6e6 solid;

    h4 {
      margin: 0;
      padding-bottom: 5px;
    }

    span {
      font-size: 14px;
      color: #888;
    }
  }
}

.headerClass {
  background: #f6fdfd;

  box-shadow: inset 0px -1px 0px 0px #eeeeee;
}

::v-deep .pagination-container .el-pagination {
  text-align: center;
  margin-top: 20px;
  display: flex;
  justify-content: center;
  position: relative;
}

::v-deep .el-pager li.active {
  cursor: default;
  font-family: MicrosoftYaHei, sans-serif;
  font-size: 12px;
  font-weight: normal;

  letter-spacing: 0em;
  color: #1dd0b7;
}

@media screen and (max-width: 767px) {
  .list {
    .breadcrumb {
      margin-left: 0;
    }
    .content {
      width: 100%;
      margin: 14px 0 44px 0;
      min-height: auto;
    }
  }

  .mobileList {
    display: block;
  }

  .bidTable,
  .bidPagination {
    display: none;
  }
}
</style>
